﻿@using Pay.Token.Utils
@model PagedResult<token_product_manage_dto>
@{ string site_img = ViewBag.img_url;}
@{
    if (Model.rows.Count > 0) {
        foreach (var row in Model.rows) {
            <li>
                <a href="javascript:void(0)">
                    <div class="box">
                        <div class="img">
                            <img src="@(row.main_img_url)" />
                        </div>
                        <div class="hidden">
                            <p class="tit">
                                @row.name
                            </p>
                            <div class="col-gray">
                                分销价：<em class="col-red">@(row.price.ToString("f2"))</em> <em class="fn20">元</em> <br>
                                佣金：<em class="col-red">@(DistributionHelper.GetProfitByLevel(row.distribution_price, ViewBag.UserType).ToString("f2"))</em><em class="fn20">元</em> <br>
                                库存：<em class="">@row.stock</em> <br>
                                邮费：
                                @if (row.freight > 0) {
                                    <em class="col-red">@(row.freight.ToString("f2"))</em> <em class="fn20">元</em>
                                } else {
                                    <em class="col-red">包邮</em>
                                }
                                <br>
                                @if (row.is_proprietary && row.status == EDistributionProductStatus.InStock) {
                                    @:状态：<em class="col-green">@(row.audit_status == AuditStatus.PendingAudit ? "待审核" : row.audit_status == AuditStatus.Sell ? "审核通过" : "审核不通过")</em>
                                }
                                @if (row.audit_status == AuditStatus.Illegal && !string.IsNullOrEmpty(row.audit_reason)) {
                                    <div class="cause col-gray trans_3 relative">
                                        <i class="icon-arrow1 trans_3 absolute"></i>
                                        <div class="hidden">
                                            原因：@row.audit_reason
                                        </div>
                                    </div>
                                }
                            </div>
                        </div>
                        <div class="btnBox" data-productId="@row.product_id" data-distributionProductId="@row.distribution_product_id" data-isProprietary="@(row.is_proprietary ? 1: 0)" data-app="@(row.is_app?1:0)">
                            @if (row.is_proprietary && row.status != EDistributionProductStatus.Failure) {
                                <button class="ui-btn ui-btn-md w120 ui-btn-red edit_btn" type="button">编辑</button>
                            }
                            @if (row.status != EDistributionProductStatus.InSales || row.is_proprietary) {
                                <button class="ui-btn ui-btn-md w120 ui-btn-cancel delete_btn" type="button">删除</button>
                            }
                            @if (row.status == EDistributionProductStatus.InSales) {
                                <button class="ui-btn ui-btn-md w120 ui-btn-cancel unShelve_btn" type="button">下架</button>
                            }
                            @if (row.status == EDistributionProductStatus.InStock) {
                                <button class="ui-btn ui-btn-md w120 ui-btn-cancel putaway_btn" type="button">上架</button>
                            }
                        </div>
                    </div>
                </a>
            </li>
        }
    }
    <page total_pages="@Model.total_pages" rows="@Model.rows.Count()" total_result="@Model.total_result"></page>
}
